writing routines that work